import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/basSubject/addOrSave',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/basSubject/',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/basSubject/addOrSave',
    method: 'post',
    data
  })
}

export function enableOrDisable(data) {
  const obj = {
    url: 'api/basSubject/enableOrDisable',
    method: 'post',
    data
  }
  return request(obj)
}

/**
 * 获取上级分类树
 * @param data
 * @returns {{method: string, data, url: string}}
 */
export function getTree(params) {
  return request({
    url: 'api/basSubject/tree',
    method: 'get',
    params
  })
}

export function basSubjectDropDownTree(params) {
  return request({
    url: 'api/dropDown/basSubjectTree',
    method: 'get',
    params
  })
}

/**
 * 获取下拉列表
 * @param data
 * @returns {{method: string, data, url: string}}
 */
export function getDropDown(params) {
  return request({
    url: 'api/dropDown/basSubjectList',
    method: 'get',
    params
  })
}

export function childBasSubjectList(params) {
  return request({
    url: '/api/dropDown/childBasSubjectList',
    method: 'get',
    params
  })
}

export function basSubjectIncurredAmount(params) {
  return request({
    url: '/api/basSubject/basSubjectIncurredAmount',
    method: 'get',
    params
  })
}

export default {add, edit, del, enableOrDisable, basSubjectDropDownTree, getDropDown}
